{% extends '_base.html' %}
{% block script %}
<script language="javascript"> 
    function toggle(showHideDiv, switchTextDiv, hiddenValue) {
        var ele = document.getElementById(showHideDiv);
        var text = document.getElementById(switchTextDiv);
        var hid = document.getElementById(hiddenValue)
        if(ele.style.display == "block") {
            ele.style.display = "none";
            text.innerHTML = "Restore";
            hid.value="Deleted";
        }
        else {
            ele.style.display = "block";
            text.innerHTML = "Delete";
            hid.value="Normal";
        }
    } 
</script>
{% endblock %}
{% block content %}
<form method="post" action="/cell">
    <input type="hidden" name="label" value="{{b.label}}">
    <p>label: {{b.label}} </p>
    <p>url: <input type="text" name="url" value="{{b.url}}"></p>
    <p>description: <input type="text" size=64 name="des"  value="{{b.description}}"></p>
    {% for k in b.stuffs %}
    <hr class="separator">
    <input type="hidden" id='hidden_{{k.ID()}}' name='hidden_{{k.ID()}}' value='Normal'>
    <table>
      <td><a id='stats_stuff_{{k.ID()}}' class="delbutton" href="javascript:toggle('div_stuff_{{k.ID()}}','stats_stuff_{{k.ID()}}', 'hidden_{{k.ID()}}');">Delete</a></td>
    </table>
    <div id="stuff">
      <div id='div_stuff_{{k.ID()}}' style='display: block;'>
        <table>
          <tr>
            <td><p>pattern: <input type="text" name="pattern_{{k.ID()}}" value='{{k.pattern|e}}' ></p> </td>
            <td><p>message: <input type="text" name="message_{{k.ID()}}" value='{{k.message|e}}' ></p> </td>
          </tr>
          <tr>
            <td><p>lambda: <input type="text" name="lambda_{{k.ID()}}" value='{{k.expression|e}}' ></p></td>
            <td><p>param1: <input type="text" name="p1_{{k.ID()}}" value='{{k.p1|e}}' ></p></td>
            <td><p>param2: <input type="text" name="p2_{{k.ID()}}" value='{{k.p2|e}}' ></p></td>
          </tr>
        </table>
      </div>
    </div>
    {% endfor %}
    <hr class="separator">
    <div id="newstuff">
      <table>
        <tr>
          <td><p>pattern: <input type="text" name="pattern" value='{{n.pattern|e}}' ></p> </td>
          <td><p>message: <input type="text" name="message" value='{{n.message|e}}' ></p> </td>
        </tr>
        <tr>
          <td><p>lambda: <input type="text" name="lambda" value='{{n.expression|e}}' ></p></td>
          <td><p>param1: <input type="text" name="p1" value='{{n.p1|e}}' ></p></td>
          <td><p>param2: <input type="text" name="p2" value='{{n.p2|e}}' ></p></td>
        </tr>
      </table>
    </div>
    <p><input type="submit" name="Update" value="Update" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    {% if b.isRunning %}
    <input type="submit" name="Withdraw" value="Withdraw" ></p>
    {% else %}
    <input type="submit" name="Launch" value="Lauch" ></p>
    {% endif %}
</form>
{% endblock %}
{% block errmessage %}
<p>{{e}}</p>
{% endblock %}
{% block message %}
<p>{{m}}</p>
{% endblock %}
